#1. 确定CMake的最低版本需求
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)

#2. 确定工程名
PROJECT(LoaderRunner LANGUAGES CXX)
SET(CMAKE_CXX_STANDARD 17)

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/Loader)

INCLUDE_DIRECTORIES(${INCS})
LINK_DIRECTORIES(${LNKS})

SET(LIBS
	WtBtCore
	WTSTools
	WTSUtils
)

IF(MSVC)
ELSE(GNUCC)
	LIST(APPEND LIBS
		dl)
	if(WIN32)
		LIST(APPEND LIBS iconv)
	ENDIF()
ENDIF()

#添加源码
file(GLOB SRCS *.cpp)
file(GLOB HDRS *.h)


#9. 生成可执行文件
ADD_EXECUTABLE(LoaderRunner ${SRCS} ${HDRS})
TARGET_LINK_LIBRARIES(LoaderRunner ${LIBS})

IF (MSVC)
ELSE (GNUCC)
	SET_TARGET_PROPERTIES(LoaderRunner PROPERTIES
        LINK_FLAGS_RELEASE -s)
ENDIF ()

#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/WtBtPorter)
#ADD_EXECUTABLE(TestBtPorter ../TestBtPorter/TestBtPorter.cpp)
#TARGET_LINK_LIBRARIES(TestBtPorter ${LIBS})

message(${CMAKE_SOURCE_DIR})
set(DIST_CTPLoader_DIR ${CMAKE_SOURCE_DIR}/../dist/LoaderRunner)

file(MAKE_DIRECTORY ${DIST_CTPLoader_DIR}/flow/)
file(MAKE_DIRECTORY ${DIST_CTPLoader_DIR}/traders/)

add_custom_command(TARGET LoaderRunner POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E
	copy ${EXECUTABLE_OUTPUT_PATH}/LoaderRunner ${DIST_CTPLoader_DIR})